package com.open4cn.simulator.device.datacolor;

import com.open4cn.simulator.core.device.DeviceStatus;
import com.open4cn.simulator.core.device.IDeviceStatusChanger;
import com.open4cn.simulator.core.ext.DataColorStatus;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description
 * @Email yinxiaopeng@zj.tech
 * @date 2022-05-19 21:45
 */
public class DataColorStatusChanger implements IDeviceStatusChanger {
    @Override
    public void change(DeviceStatus deviceStatus, String key, Object value) {
        if (null == key || null == value) {
            return;
        }

        DataColorStatus dataColorStatus = (DataColorStatus) deviceStatus.getData();
        if ("specularGloss".equalsIgnoreCase(key)) {
            changeSpecularGloss(dataColorStatus, value);
            return;
        }

        if ("aperture".equalsIgnoreCase(key)) {
            changeAperture(dataColorStatus, value);
            return;
        }

        if ("uv".equalsIgnoreCase(key)) {
            changeUV(dataColorStatus, value);
            return;
        }
    }


    /**
     * 更改包含状态
     *
     * @param dataColorStatus
     * @param value
     */
    private void changeSpecularGloss(DataColorStatus dataColorStatus, Object value) {
        DataColorStatus.SpecularGlossEnum specularGlossEnum = DataColorStatus.SpecularGlossEnum.valueOf((String) value);
        if (null != specularGlossEnum) {
            dataColorStatus.changeSpecularGloss(specularGlossEnum);
        }
    }


    /**
     * 切换孔径
     *
     * @param dataColorStatus
     * @param value
     */
    private void changeAperture(DataColorStatus dataColorStatus, Object value) {
        DataColorStatus.ApertureEnum apertureEnum = DataColorStatus.ApertureEnum.valueOf((String) value);
        if (null != apertureEnum) {
            dataColorStatus.changeAperture(apertureEnum);
        }
    }


    /**
     * 更改uv状态
     *
     * @param dataColorStatus
     * @param value
     */
    private void changeUV(DataColorStatus dataColorStatus, Object value) {
        DataColorStatus.UVEnum UVEnum = DataColorStatus.UVEnum.valueOf((String) value);
        if (null != UVEnum) {
            dataColorStatus.changeUV(UVEnum);
        }
    }
}
